1 00:00:00,540 --> 00:00:04,380 Hello and welcome to this lecture in this lecture. 2 00:00:04,380 --> 00:00:10,610 We all be creating the functionality for our app using javascript. 3 00:00:10,620 --> 00:00:14,290 This is going to be a two part lecture series. 4 00:00:14,340 --> 00:00:19,940 So this part one we'll start and we'll finish off in part two. 5 00:00:21,750 --> 00:00:25,560 So this is my javascript file. 6 00:00:25,710 --> 00:00:33,240 The way this letter is going to work I am going to write the code added code on and then explain it. 7 00:00:33,240 --> 00:00:40,770 So to start with I'm going to create a variable that I will call questions and his sound is variable. 8 00:00:40,800 --> 00:00:48,030 He's going to have one set variable two equals two and three sound inside that area. 9 00:00:48,040 --> 00:00:55,500 We also have objects that will include the questions for the quiz. 10 00:00:55,590 --> 00:01:00,130 The choices you have to make and then the correct answer. 11 00:01:00,390 --> 00:01:08,460 So we'll go from the law of use up inside variable and set that variable to equal to an array and their 12 00:01:08,460 --> 00:01:17,560 array with contain objects are also array within that object as well right. 13 00:01:17,580 --> 00:01:25,920 I have added some code on a chunk of code so land one here have created a variable called questions. 14 00:01:26,220 --> 00:01:28,170 Okay and I've said that to you. 15 00:01:28,210 --> 00:01:30,970 So are narey So does the beginning. 16 00:01:31,460 --> 00:01:36,290 He fires crews down and the hairy end on line. 17 00:01:36,300 --> 00:01:37,700 Fifty three here. 18 00:01:37,710 --> 00:01:40,370 So this is the clues in Harry. 19 00:01:40,510 --> 00:01:42,660 And it's said that Harry. 20 00:01:42,690 --> 00:01:46,890 You've also got objects so where you see curly braces. 21 00:01:47,070 --> 00:01:51,570 You know that you're looking at an object where you see a square brackets. 22 00:01:51,570 --> 00:01:58,100 Know that you are looking at an Harry saw inside this Harry and the object. 23 00:01:58,170 --> 00:01:59,610 We've got the question. 24 00:01:59,850 --> 00:02:02,830 So this is a question that the quiz will ask. 25 00:02:03,060 --> 00:02:03,970 Then this. 26 00:02:04,050 --> 00:02:13,870 This is the natural question with an object you need to have a property and then obviously the value. 27 00:02:14,250 --> 00:02:16,760 So the question would be the property. 28 00:02:16,770 --> 00:02:21,600 And this question here this reply here will be the value. 29 00:02:21,860 --> 00:02:24,770 So I'm asking a question and this is the question. 30 00:02:25,020 --> 00:02:26,490 And there are online three here. 31 00:02:26,520 --> 00:02:32,630 Got another object property or choices and the value is equal to an array. 32 00:02:32,670 --> 00:02:36,860 So he said that a rate is where the answers will be. 33 00:02:37,140 --> 00:02:42,670 So look in true that Arey the correct answer would be three and three. 34 00:02:42,690 --> 00:02:49,800 When you are accessing the elements in an hour and the reason it is zero B's index So the first one 35 00:02:49,800 --> 00:02:52,290 is known that is zero so this would be B B. 36 00:02:52,350 --> 00:02:53,160 It is here. 37 00:02:53,160 --> 00:02:59,420 The correct answer is 3 Well it would be 0 1 2 3 weeks lava. 38 00:02:59,640 --> 00:03:07,440 So just remember that when your numbering in an hour is starts is zero B's index the first one is usually 39 00:03:07,740 --> 00:03:08,390 0. 40 00:03:08,490 --> 00:03:12,870 So I saw the format for this. 41 00:03:12,870 --> 00:03:17,030 Here is the format for all the questions inside. 42 00:03:17,100 --> 00:03:18,780 Yes I agree. 43 00:03:19,560 --> 00:03:27,850 So all these are values of this variable called Question everything here belongs to this variable questions 44 00:03:28,170 --> 00:03:29,260 saw. 45 00:03:29,420 --> 00:03:31,150 The format is the same. 46 00:03:31,170 --> 00:03:38,650 I ask a question which is the property value which is the actual question. 47 00:03:38,730 --> 00:03:47,350 The choices are includes inside an array and then we use the index base to pick up correct answers. 48 00:03:47,550 --> 00:03:54,190 The format is the same all through okay and thus the very last question. 49 00:03:54,200 --> 00:03:57,530 So you don't have to use the same. 50 00:03:57,560 --> 00:04:01,650 I have used baby names of fundaments where you could do something. 51 00:04:01,650 --> 00:04:05,850 You are completely interested in if you don't if you don't want to follow use baby. 52 00:04:05,940 --> 00:04:11,510 So just as long as a format is the same you should the quiz should work as well. 53 00:04:11,660 --> 00:04:12,340 Alright. 54 00:04:12,470 --> 00:04:14,550 But any parts of this you don't understand. 55 00:04:14,550 --> 00:04:25,090 Please feel free to let me in a line 55 56 57 new variables I have added the first variable is called 56 00:04:25,110 --> 00:04:33,780 here corrent question set the value set to zero the correct answer is the value set to zero variable 57 00:04:34,500 --> 00:04:36,940 var is set to false. 58 00:04:36,960 --> 00:04:43,350 So all of these variables are set to zero or false. 59 00:04:43,360 --> 00:04:45,070 False is a bully and value. 60 00:04:45,400 --> 00:04:46,760 Is this true. 61 00:04:47,040 --> 00:04:51,550 If we say that the result is either one or the other so is that true or false. 62 00:04:51,750 --> 00:05:03,250 So with these values given the variables at the moment I have saw more code here from line 59. 63 00:05:03,390 --> 00:05:07,880 The way to a line 91. 64 00:05:08,290 --> 00:05:08,720 Oh right. 65 00:05:08,730 --> 00:05:15,620 Let me walk you to the code line 59 when wherever you see dollar. 66 00:05:15,660 --> 00:05:20,380 I know that you are referencing a jig query library. 67 00:05:20,970 --> 00:05:27,980 59 basically say it's documented Dort ready function what this function does. 68 00:05:28,010 --> 00:05:39,290 It checks to make sure that the page is fully loaded before it executes the code. 69 00:05:39,440 --> 00:05:45,860 Dr. Reddy is what checks to make sure that the page simply is fully loaded so that you decode is not 70 00:05:46,340 --> 00:05:54,610 executed prematurely before DP is fully loaded and diphthong chant whatever happens was a pay use law 71 00:05:54,620 --> 00:05:59,370 that is displayed within the function which is this calibrators here. 72 00:05:59,390 --> 00:06:05,830 We start online 59 and ends online 91. 73 00:06:05,960 --> 00:06:12,370 So let me run through the code with you line 16. 74 00:06:12,710 --> 00:06:18,060 This play the current question what that is it will display the very first question. 75 00:06:18,350 --> 00:06:19,230 Okay. 76 00:06:19,590 --> 00:06:25,130 Then six to one dollar and then did this inside the perimeter. 77 00:06:25,130 --> 00:06:29,900 This refers to the current element is referring to. 78 00:06:29,900 --> 00:06:38,650 So you say this got fined imperance this is so it will look for the next squeeze message dot hide or 79 00:06:38,760 --> 00:06:39,550 key. 80 00:06:39,590 --> 00:06:43,140 So what that means is that it hides the other's body. 81 00:06:43,160 --> 00:06:44,990 Pfizer the current one. 82 00:06:45,040 --> 00:06:45,650 Right. 83 00:06:45,880 --> 00:06:52,720 And then line 62 then use the next button is say lower. 84 00:06:52,880 --> 00:06:54,830 And then it's passed in this. 85 00:06:55,110 --> 00:07:05,560 What did this metter does using a DOD find a tool pick out the next question is in the next button. 86 00:07:05,870 --> 00:07:06,320 Okay. 87 00:07:06,330 --> 00:07:10,480 And you notice the ever tight a dot dot on methot here. 88 00:07:10,760 --> 00:07:16,440 And this metod toke seem to permeate out and the click which is event function. 89 00:07:16,520 --> 00:07:25,130 So when there is a click on the button it wall the click will be the event it'll trigger of this function 90 00:07:25,130 --> 00:07:35,540 here which is the what happens between this calibrators And was this embrace this yes everything in 91 00:07:35,540 --> 00:07:40,700 here will be triggered it was the next button is clicked. 92 00:07:41,420 --> 00:07:49,010 So I've got an if statement online six three saying if the question marks be as clear to me that if 93 00:07:49,010 --> 00:08:00,640 the quiz is not over then the value equals two dollar which is a good query import type radio button. 94 00:08:00,660 --> 00:08:07,420 If the your but is checked and the value the value of the Reagan put in this check and the quiz is not 95 00:08:07,450 --> 00:08:08,230 over. 96 00:08:08,540 --> 00:08:17,060 And if the value is not on defined diva value was not known to do this good pick up the document. 97 00:08:17,090 --> 00:08:24,770 Fine fine look for the message look for the text and then select the right answer which will prompt 98 00:08:24,770 --> 00:08:26,820 you to select the right answer. 99 00:08:26,830 --> 00:08:34,770 Line 6 is 7 again since 6 similar approach looks picks up the quiz and then uses it. 100 00:08:34,770 --> 00:08:39,440 Not sure method to display the quiz. 101 00:08:39,860 --> 00:08:50,380 If that is were then an STD meant there are two conditions for seeing if the acquis is not over do this. 102 00:08:50,460 --> 00:08:56,610 But if the quiz is over do this find this document the dodge. 103 00:08:56,620 --> 00:09:02,110 Find me in this fine method this quiz and then hide it. 104 00:09:02,150 --> 00:09:09,890 The value is equal to questions and it passed in the current question and the answer is correct then 105 00:09:09,920 --> 00:09:11,930 correct answer. 106 00:09:11,930 --> 00:09:16,010 You know you add the correct answer lattman What that means. 107 00:09:16,010 --> 00:09:25,580 If the current question plus blows means if this increase in the question is a current question is less 108 00:09:25,640 --> 00:09:31,280 than the question length lenthall the question displayer the current question. 109 00:09:31,280 --> 00:09:33,700 Else display the score. 110 00:09:33,960 --> 00:09:34,620 Okay. 111 00:09:34,730 --> 00:09:38,020 So again using the query library again. 112 00:09:38,180 --> 00:09:42,980 If the documents are fine till next button is not. 113 00:09:43,430 --> 00:09:46,810 Once in a good bisley what's the same if you click on the next button. 114 00:09:46,910 --> 00:09:49,960 It should display the. 115 00:09:50,050 --> 00:09:55,940 It should give you a prompt to play bequeaths again see if the quiz is over. 116 00:09:56,090 --> 00:09:58,720 If the quiz is over quiz is all right. 117 00:09:58,770 --> 00:10:00,560 Drew them as the game is over. 118 00:10:00,680 --> 00:10:01,900 You can start again. 119 00:10:01,940 --> 00:10:11,370 That's where else else statement here where if all that force false is it acquisitional that do this. 120 00:10:11,390 --> 00:10:14,370 Click on the next Botting get to this question. 121 00:10:14,610 --> 00:10:20,460 If not the case of the quizzes over race you can reset the quiz using this function. 122 00:10:20,730 --> 00:10:22,720 Display the corner oquist John. 123 00:10:22,810 --> 00:10:30,090 You can hide the score so just Kois hid in on to the quiz or the questions I've been answered. 124 00:10:30,090 --> 00:10:32,210 So that is it. 125 00:10:32,220 --> 00:10:36,480 We've got to stop here for this lecture cause he's gone a bit long. 126 00:10:36,600 --> 00:10:43,220 So we started off by defining variable and setting in the questions. 127 00:10:43,410 --> 00:10:46,470 The question choices be answers. 128 00:10:46,720 --> 00:10:47,340 Okay. 129 00:10:47,400 --> 00:10:50,280 And then we moved on. 130 00:10:50,310 --> 00:10:54,030 These are all the questions okay. 131 00:10:54,600 --> 00:10:59,290 And then we moved down to set three variables there. 132 00:10:59,400 --> 00:11:05,170 We also have Blue Dog komenda read the method and thus the rest of it. 133 00:11:05,400 --> 00:11:09,890 So that's it for this lecture war completed in part two. 134 00:11:10,020 --> 00:11:11,180 Thanks for watching. 135 00:11:11,370 --> 00:11:13,620 There's any aspects you do not understand. 136 00:11:13,620 --> 00:11:15,780 Please feel free to let me know. 137 00:11:15,780 --> 00:11:16,660 Bye for now.